package lambda;

import java.io.File;
import java.io.FileFilter;

/**
 * JDK8以后推出lambda表达式
 *当接口中只有一个抽象方法时可以使用lambda表达式
 *
 */
public class LambdaDemo {
    public static void main(String[] args) {
/*        FileFilter fileFilter = new FileFilter() {
            @Override
            public boolean accept(File pathname) {
                return pathname.getName().contains("t");
            }
        };
        FileFilter filter = (p) -> p.getName().contains("t");
        */

        File dir = new File("./src/file");
        File[] subs = dir.listFiles((pathname) -> pathname.getName().contains("t"));
        for (int i = 0; i < subs.length; i++) {
            System.out.println(subs[i].getName());
        }
    }
}
